package com.futurescale.sa.model.vo
{
	/**
	 * A Milieu is a group of settings that can appear 
	 * in one or more stories or episodes of a series. 
	 * This value object represents a milieu and its 
	 * associated settings. 
	 */
	[Bindable] 
	public class MilieuVO extends ValueObject
	{
		/**
		 * The XML element name.
		 */
		public static const ELEMENT:String = "Milieu";
		
		/**
		 * Construct a MilieuVO.
		 */
		public function MilieuVO( xml:XML=null )
		{
			super( ELEMENT, xml );
		}
		
		/** 
		 * An name-sorted Vector of a Milieu's Settings.
		 */
		public function get settings():Vector.<SettingVO>
		{
			var v:Vector.<SettingVO> = new Vector.<SettingVO>();
			var xl:XMLList = xml..Setting;
			for each ( var sx:XML in xl ) {
				var setting:SettingVO = new SettingVO(sx);
				v.push( setting );
			}
			v.sort( ValueObject.nameSort );
			return v;
		}
		public function set settings( v:Vector.<SettingVO> ):void 
		{} // read-only but bindable
		
		/**
		 * Add a Setting to the Milieu.
		 */
		public function addSetting( setting:SettingVO ):void
		{
			xml.appendChild( setting.xml );
		}
	}
}